<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <script type="text/javascript">  

              function attrtakeMyValue(val,id) {  
                 // alert(val.value);
               document.getElementById("mainForm:DMAttributesPropValueHidden").value=val.value;
               document.getElementById("mainForm:DMAttributesPropValueIDHidden").value=id;
               attrRemoteCMD1();
              }  
    </script> 

    <h:inputHidden id="DMAttributesPropValueHidden" value="#{generateWizardBean.updateDmAttrPropTable.value}"/>
    <h:inputHidden id="DMAttributesPropValueIDHidden" value="#{generateWizardBean.updateDmAttrPropTable.ID}"/>

    <p:remoteCommand name="attrRemoteCMD1" action="#{generateWizardBean.updateAttrPropVal}" 
                     process="@this,DMAttributesPropValueIDHidden,DMAttributesPropValueHidden" update="list_growl,step4MSG"/>
    <p:messages id="step4MSG" showDetail="true" />


    <p:panel header="Attributes">


        <h:panelGrid columns="2" columnClasses="label, value">


            <h:panelGrid  columns="2" columnClasses="label, value">
                <h:selectOneListbox size="5"   id="dataModelObjects_IDTxt_2"
                                    value="#{generateWizardBean.selectedDataModelObjectTable.ID}"
                                    required="false"
                                    rendered="true"
                                    requiredMessage="dataModelProject is Mandatory" onchange="remoteCMDRefresh_attrListBox();">
                    <f:selectItems value="#{generateWizardBean.dataModelObjectsList}" />
                </h:selectOneListbox>

                <h:selectOneListbox size="5"   id="dataModelAttributes_IDTxt"
                                    value="#{generateWizardBean.selectedDataModelAttributesTable.ID}"
                                    required="false"
                                    rendered="true"
                                    requiredMessage="dataModelProject is Mandatory" onchange="remoteCMDRefresh_attr();">
                    <f:selectItems value="#{generateWizardBean.dataModelAttributesList}" />
                </h:selectOneListbox>

            </h:panelGrid>

            <p:commandButton value="New" id="new_attrect" oncomplete="add_attr_dm_dialog.show()"/>
            <p:commandButton rendered="false" value="Edit" id="edit_attrect" oncomplete="varaddNewProjectDialog.show()"/>

            <p:remoteCommand name="remoteCMDRefresh_attr" action="#{generateWizardBean.refreshAttributesProperties}" process="@this, dataModelAttributes_IDTxt" update="@this,dt1_attr"/>
            <p:remoteCommand name="remoteCMDRefresh_attrListBox" action="#{generateWizardBean.getAllDataModelAttributes}" process="@this,dataModelObjects_IDTxt_2" update="@this,dataModelAttributes_IDTxt"/>


        </h:panelGrid>


    </p:panel>


    <p:dataTable id="dt1_attr" var="info" value="#{generateWizardBean.dmAttrPropTables}">

        <p:column>
            <f:facet name="header">
                <h:outputText value="Code" />
            </f:facet>
            <h:outputText  id="attrPropCode_outputText" value="#{info.attrPropCode}" />
            <p:tooltip for="attrPropCode_outputText" value="#{info.attrPropDescr}"
                       showEffect="slide" hideEffect="slide" 
                       showEffectLength="500" hideEffectLength="500"/>

        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Value" />
            </f:facet>
            <h:inputText rendered="#{info.attrPropType == 'inputtext'}" value="#{info.value}" id="attrinputTxt12" onblur="attrtakeMyValue(this,#{info.ID});" />
            <h:selectOneRadio rendered="#{info.attrPropType == 'truefalse'}" value="#{info.value}" id="attrinputRadioBx12" onchange="attrtakeMyValue(this,#{info.ID});" >
                <f:selectItem itemLabel="true" itemValue="true"/>
                <f:selectItem itemLabel="false" itemValue="false"/>
            </h:selectOneRadio>
        </p:column>



    </p:dataTable>
    <p:remoteCommand name="showUpdateDialog_attr" oncomplete="varupdate_dm_Attr_prp_dialog.show()" process="@this" update="@this,update_dm_Attr_prp_dialog"/>
    <p:remoteCommand name="refreshDT_attr" process="@this"  update="dataModelAttributes_IDTxt"/>

    <h:outputLink id="link1" value="/PrimeCodeGenerator/faces/Services/Step6_Targets.xhtml">
        <h:outputText value="Steps 6" />
    </h:outputLink>

    <p:dialog id="add_Attr_dm_dialog"  header="Add New Data Model Attributes" widgetVar="add_attr_dm_dialog"
              modal="true" draggable="false" showEffect="fade" width="500" height="300" closeOnEscape="false">

        <table>

            <tr>
                <td>    <h:outputLabel rendered="true" value="Value" /></td>
            <td>:</td>
            <td>
            <h:inputText  id="ins_dataModelAttributes_Txt"
                          value="#{generateWizardBean.insertDataModelAttributesTable.code}"
                          required="false"
                          rendered="true"
                          requiredMessage="Attributes Name is Mandatory"/>
            </td>
            </tr>
            <tr>
                <td>    <h:outputLabel rendered="true" value="DataType" /></td>
            <td>:</td>
            <td>
            <h:selectOneMenu  id="ins_dataModelAttributesDataType_Txt"
                              value="#{generateWizardBean.insertDataModelAttributesTable.dataType}"
                              required="false"
                              rendered="true"
                              requiredMessage="Attributes Name is Mandatory">
                <f:selectItems value="#{generateWizardBean.attributesDataTypeArrayList}"/>

            </h:selectOneMenu>
            </td>
            </tr>


        </table>

        <h:panelGrid >
            <p:commandButton process="@this,ins_dataModelAttributes_Txt, ins_dataModelAttributesDataType_Txt" update="dataModelAttributes_IDTxt"
                             value="update" title="Update DmAttrProp" action="#{generateWizardBean.addNewDMAttributes}" oncomplete="add_attr_dm_dialog.hide();refreshDT_attr();"  />
        </h:panelGrid>
    </p:dialog>

</html>